module.exports = {
    formatTime (time, format) {
        if(typeof(time) != 'number'){
            if(typeof(time) == 'string' && /^\d+$/.test(time)){
                time = Number(time);
            }else if(typeof(time) == 'object' && time instanceof Date){
                time = time.getTime();
            }else{
                return null
            }
        }
        format = format || 'yyyy/MM/dd hh:mm:ss';
        var months = { Jan: '01', Feb: '02', Mar: '03', Apr: '04', May: '05', Jun: '06', Jul: '07', Aug: '08', Sept: '09', Oct: '10', Nov: '11', Dec: '12' };
        var tArr = new Date().toString().split(/[\s\:]/g);
        return format.replace(/yyyy/i, tArr[3]).replace(/MM/g, months[tArr[1]]).replace(/dd/ig, tArr[2]).replace(/hh/ig, tArr[4]).replace(/mm/g, tArr[5]).replace(/ss/ig, tArr[6]);
    }

};